package org.edu.modules.stu.zhsz.service.impl;

import org.edu.common.base.BasePageDto;
import org.edu.common.base.BaseServiceImpl;
import org.edu.common.utils.ConvertUtils;
import org.edu.common.base.BaseServiceImpl;
import org.edu.modules.stu.zhsz.dto.VeStuCheckItemVo;
import org.edu.modules.stu.zhsz.entity.VeStuCheckJudger;
import org.edu.modules.stu.zhsz.mapper.VeStuHygieneJudgerMapper;
import org.edu.modules.stu.zhsz.entity.VeStuHygieneJudger;
import org.edu.modules.stu.zhsz.dto.VeStuHygieneJudgerDto;
import org.edu.modules.stu.zhsz.service.VeStuHygieneJudgerService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;



/**
 * 实现类
 */
@Service
public class VeStuHygieneJudgerServiceImpl extends BaseServiceImpl<VeStuHygieneJudger, VeStuHygieneJudgerMapper> implements VeStuHygieneJudgerService {

    public IPage<VeStuHygieneJudgerDto> pageDto(BasePageDto page, @Param(Constants.WRAPPER) Wrapper queryWrapper){
        return mapper.pageDto(page,queryWrapper);
    }
    /**
    * 查询实体类
    */
    public VeStuHygieneJudgerDto findDtoById(String id) {
        VeStuHygieneJudger entity = super.findById(id);
        VeStuHygieneJudgerDto dto = ConvertUtils.convertToDto(entity, VeStuHygieneJudgerDto.class);
        return dto;
    }

    /**
    * 新增或者修改
    */
    public void insertOrUpdate(VeStuCheckItemVo dto, Boolean isAdd){
        mapper.deleteByPid(dto.getItemId()+"");
        List<VeStuHygieneJudger> list = new ArrayList<>();
        for (int i = 0; i < dto.getIds().size(); i++) {
            String id = dto.getIds().get(i);
            String name = dto.getNames().get(i);
            VeStuHygieneJudger ddd  = new VeStuHygieneJudger();
            ddd.setItemId(dto.getItemId());
            ddd.setJudgeUserId(id);
            ddd.setJudgeUserName(name);
            list.add(ddd);
        }
        super.insert(list);
    }

    @Override
    public void importExcel(List<Map<String, Object>> mapList){
        for (Map map: mapList) {
            VeStuHygieneJudgerDto dto = new VeStuHygieneJudgerDto();
                   //         dto.setJudgeUserId ((String)map.get(0000));
                   //         dto.setJudgeUserName ((String)map.get(0000));
                   //         dto.setItemId ((String)map.get(0000));
            
            super.insert(dto);
        }

    }

}
